from sklearn.ensemble import RandomForestClassifier
# from sklearn.ensemble import RandomForestRegressor
from sklearn.datasets import load_iris

iris = load_iris()
X = iris.data
y = iris.target
# print(help(RandomForestClassifier))
RFC = RandomForestClassifier(n_estimators=10, max_depth=3, oob_score=True)
# oob 是 Out of bag，指每次抽样没有被抽到的样例，oob_score指用oob数据测试的效果(正确率或R_sqr)
# Bagging集成算法，可以不对数据集进行train_test_split，而是使用oob_score

RFC.fit(X, y)

print(RFC.score(X, y))
print(RFC.oob_score_)

print(RFC.predict(X[-10:]))
print(RFC.predict_proba(X[-10:]))

print(iris.feature_names)

print(RFC.feature_importances_)